package ca.scotthyndman.as2haxe.dom;

/**
 * Abstract class for classes that describe AST node properties.
 */
public abstract class ASPropertyDescriptor {

	/**
	 * Property id.
	 */
	private final String propertyId;

	/**
	 * The concrete AST node type that owns this property.
	 */
	private final Class nodeClass;

	/**
	 * Creates a new property descriptor for the given node type with the given
	 * property id. Note that this constructor is declared package-private so
	 * that property descriptors can only be created by the AST implementation.
	 * 
	 * @param nodeClass
	 *            concrete AST node type that owns this property
	 * @param propertyId
	 *            the property id
	 */
	ASPropertyDescriptor(Class nodeClass, String propertyId) {
		if (nodeClass == null || propertyId == null) {
			throw new IllegalArgumentException();
		}
		this.propertyId = propertyId;
		this.nodeClass = nodeClass;
	}

	/**
	 * Returns the id of this property.
	 * 
	 * @return the property id
	 */
	public final String getId() {
		return this.propertyId;
	}

	/**
	 * Returns the AST node type that owns this property.
	 * <p>
	 * For example, for all properties of the node type TypeDeclaration, this
	 * method returns <code>TypeDeclaration.class</code>.
	 * </p>
	 * 
	 * @return the node type that owns this property
	 */
	public final Class getNodeClass() {
		return this.nodeClass;
	}
}
